<template>
  <div class="app-container">
    <div>
      <div>{{ item.name }}</div>
      <el-divider />
    </div>
    <div class="detail">
      <div>

        <div class="detail-item">
          <p class="label">任务频次</p>
          <p class="value">{{ item.frequency == 'monthly' ? '按月' : '一次性' }}</p>
        </div>
        <div class="detail-item">
          <p class="label">数据模板</p>
          <p class="value">{{ item.sheet_template.name }}</p>
        </div>
        <div class="detail-item">
          <p class="label">任务描述</p>
          <p class="value">{{ item.description }}</p>
        </div>
        <div v-if="item.attachment" class="detail-item">
          <p v-if="item.attachment.name" class="label">附件</p>
          <!-- <p class="value" @click="downloadFile(item.attachment.url)">{{ item.attachment.name + '下载' }}</p> -->
          <p v-if="item.attachment.name">

            <a class="value" :href="item.attachment.url" :download="item.attachment.name">{{ item.attachment.name + '下载' }}</a>
          </p>
        </div>
      </div>
    </div>
    <div class="detail-btn">
      <el-button type="primary" style="width: 120px" @click="goBack">返回</el-button>
    </div>
  </div>
</template>
<script>
import axios from 'axios'
export default {
  props: {
    item: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {

    }
  },
  methods: {
    goBack() {
      this.$emit('goBack')
    }
    // downloadFile(url) {
    //   window.open(url)
    // }
    // downloadFile(url, label) {
    //   axios.get(url, { responseType: 'blob' }).then(response => {
    //     const blob = new Blob([response.data])
    //     const link = document.createElement('a')
    //     link.href = URL.createObjectURL(blob)
    //     link.download = label
    //     link.click()
    //     URL.revokeObjectURL(link.href)
    //   }).catch(console.error)
    // }

  }
}
</script>
<style lang="scss" scoped>
.detail {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  // align-items: center;
  .detail-item {
    margin: 40px 0;
    p {
      text-align: center;
      margin-bottom: 15px;
    }
    .label {
      color: #acacac;
      font-size: 14px;
    }
    .value {
      font-size: 14px;
    }
  }
}
.detail-btn {
  margin-top: 40px;
  text-align: center;
}
</style>
